# Read in both the oil spill and CA counties data

ca_counties <- read_sf(here("data","ca_counties","CA_Counties_TIGER2016.shp")) %>% 
  clean_names()

oil_spills <- read_sf(here("data","oil","ds394.shp")) %>% 
  clean_names()

# Change the CRS of the spills data to match the CRS of the counties data
oil_spills <- st_transform(oil_spills, 3857)

Exploring oil spills in California

In this report, we explore oil spill events in different counties throughout California.

To begin, using data from CA DFW Oil Spill Incident Tracking, we created an interactive map to get an overview of oil spill events in California.

# Creating an interactive map
tmap_mode(mode = "view")

tm_shape(ca_counties) +
  tm_fill("aland", palette = "BuGn") +
  tm_shape(oil_spills) +
  tm_dots()

Then, we looked at the counts of just inland oil spills (excluding marine spills), colorcoding by county to see the number of spills in each county in California.

# Making a graph for counts of inland oil spill events by county

# Begin by filtering the oil_spills subset 
inland_spills <- oil_spills %>% 
  filter(inlandmari=="Inland")

# Joining the filtered oil spills with the CA counties data
ca_spills <- ca_counties %>% 
  st_join(inland_spills)

# Finding the counts of oilspill events by county
county_counts <- ca_spills %>% 
  count(name)

ggplot(data = county_counts) +
  geom_sf(aes(fill = n), color = "white", size = 0.1) +
  scale_fill_gradientn(colors = c("lightgray","cyan","blue")) +
  theme_bw() +
  labs(fill = "Number of oil spills",
       title = "Counts of inland oil spill events by \ncounty in California (2008)")